RTC.h
#ifndef _RTC_H_
#define _RTC_H_
#include "Lampen.h"
typedef enum
{
NEGATIVE = 0x00,
POSITIVE = 0x01,
} clock_polarity;
struct Clock_struct
{
bool tick_in_progress;
bool stopped;
uint8_t clock_pin_1;
uint8_t clock_pin_2;
int16_t ticks_to_do;
int16_t ticks_memory;
clock_polarity polarity; // To determine which polatity of impulse schould be done on the next step
uint16_t ticks_timer; // Counter for counting miliseconds for impulse switching;
uint16_t impulse_period; // Period of the active signal on a pin (ms). must always be less then tick_period (П_ - the Period of П)
uint16_t duty_cycle; // duty_cycle of a tick, %
uint16_t tick_period; // Tick period (ms) according to impulse_period and duty_cycle (written here to simplify calculations. DO NOT OWERWRITE AFTER init_clock() FUNCTION!!!)
};
typedef struct Clock_struct my_clock_t;
void RTC_Set_Time(status_flags_t* Status, ts* time_struct);
int16_t calculate_Ticks(ts* RTC_time, my_time_t* EEPROM_time);
void init_clock(my_clock_t* Clock);
void do_impulse(my_clock_t* Clock);
#endif /* _RTC_H_ */